<template>
	<view>
		<view class="page-body">
			<view class="page-section page-section-gap">
				<map style="width: 100%; height: 1350rpx;" :latitude="latitude" :longitude="longitude" :markers="covers">
				</map>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0, // 使用 marker点击事件 需要填写id
				title: 'map',
				latitude: 30.676965,
				longitude: 104.075959,
				covers: []
			}
		},
		onLoad() {
			this.getlist()
			this.getNativeLocation()
		},
		methods: {
			//获取当前位置
			getNativeLocation(){
				uni.getLocation({
					type: 'wgs84',
					success: function (res) {
						console.log(res)
					    console.log('当前位置的经度：' + res.longitude);
					    console.log('当前位置的纬度：' + res.latitude);
					    this.latitude = res.latitude;
						this.longitude = res.longitude
					}
				})

				
			},
			getlist() {
				uni.request({
					url: 'http://39.106.207.209:8100/interview/getInterviewAll', 
					method:'get',
					success: (res) => {
						this.covers = [];
						for (var i = 0; i < res.data.data.length; i++) {
							var item = {
								latitude: res.data.data[i].latlang.split(",")[1],
								longitude: res.data.data[i].latlang.split(",")[0],
								iconPath: '../../static/marker.png'
							}
							this.covers.push(item)
						}
					}
				});
			}
		}
	}
</script>

<style>
		

</style>
